package com.firewolf.spring.beanlife;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessAfterInitialization(Object arg0, String arg1) throws BeansException {
		System.out.println("postProcessAfterInitialization :  BeanName = " + arg1 + "    bean" + arg0);
		// 这里可以修改Bean，
		// 由于这个处理器会对所有的Bean进行管理，这里可能会出现很多的if判断：
		// if("car".equals(arg1)){
		// 进行处理
		// }
		return arg0;
	}

	@Override
	public Object postProcessBeforeInitialization(Object arg0, String arg1) throws BeansException {
		// TODO Auto-generated method stub
		System.out.println("postProcessBeforeInitialization :  BeanName = " + arg1 + "    bean" + arg0);
		return arg0;
	}

}
